// FRAOZO - 3a
// Contains the definition of the dictionary class

#include <iostream>
#include <vector>

class dictionary
{
  public:
   dictionary();
   void readInputFile(const string &fileName);
   void printDict() const;
   int getSize() const;
   string idxString(int idx) const;

  private:
   vector<string> words;
};

dictionary::dictionary()
:words()
{}
   
void dictionary::readInputFile(const string &fileName)
//Opens fileName if possible and pushes each string into the 
// words vector
{
   ifstream inputFile;

   string currentWord;

   inputFile.open(fileName.c_str());
   if (!inputFile)
      throw (baseException ("Can't open dictionary file"));
 
   while (inputFile >> currentWord)
      words.push_back(currentWord);

   inputFile.close();
    
}

void dictionary::printDict() const
//Print the contents of the dictionary, one word per line
{
   for (int i=0; i<words.size(); i++)
      std::cout << words[i] << std::endl;
}

int dictionary::getSize() const
{
   return words.size();
}

string dictionary::idxString (int idx) const
{
   return words.at(idx);
}
